babl: export symbol babl_space_to_icc
authorØyvind Kolås <pippin@gimp.org>
Sun, 8 Jul 2018 20:38:25 +0000 (22:38 +0200)
committerØyvind Kolås <pippin@gimp.org>
Sun, 8 Jul 2018 20:38:25 +0000 (22:38 +0200)
babl/babl-icc.c
babl/babl-internal.h
babl/babl.h
export-symbols

index 918b81ed7c9ef2d7260b565e79d9ddd2ca52895d..ed6e0ccb87b920d73fbed0efe86a82a49e83859f 100644 (file)
@@ -484,14 +484,14 @@ switch (trc->type)
 
 static void symmetry_test (ICC *state);
 
-const char *babl_space_to_icc (const Babl  *babl,
-                               const char  *description,
-                               const char  *copyright,
-                               BablICCFlags flags,
-                               int         *ret_length)
+char *babl_space_to_icc (const Babl  *babl,
+                         const char  *description,
+                         const char  *copyright,
+                         BablICCFlags flags,
+                         int         *ret_length)
 {
   const BablSpace *space = &babl->space;
-  static char icc[65536];
+  char icc[65536];
   int length=65535;
   ICC *state = icc_state_new (icc, length, 10);
 
@@ -606,7 +606,11 @@ const char *babl_space_to_icc (const Babl  *babl,
     *ret_length = length;
 
   babl_free (state);
-  return icc;
+  {
+    char *ret = malloc (length);
+    memcpy (ret, icc, length);
+    return ret;
+  }
 }
 
 
index 8645f902beacdeb66c9350d5b844af155c01948b..2a0094d416c5e05121b6e264504eabdea7c9b8a5 100644 (file)
@@ -410,25 +410,7 @@ int _babl_file_get_contents (const char  *path,
                              long        *length,
                              void        *error);
 
-typedef enum {
-  BABL_ICC_DEFAULTS = 0,
-  BABL_ICC_COMPACT_TRC_LUT = 1,
-} BablICCFlags;
 
-/* babl_space_to_icc:
- *
- * Creates an ICCv2 RGB matrix profile for a babl space. The profiles strive to
- * be as small and compact as possible, TRCs are stored as 1024 entry LUT(s).
- *
- * you should make a copy of the profile before making another call to this
- * function.
- */
-
-const char *babl_space_to_icc (const Babl  *space,
-                               const char  *description,
-                               const char  *copyright,
-                               BablICCFlags flags,
-                               int         *icc_length);
 
 /* babl_space_get_rgbtoxyz:
 
index 1d7d43394c0ce64fcf46ce9b3b447ec038b84f5d..f6ba782723bcf85bdb38440241bf4f0fd3d9a264 100644 (file)
@@ -488,6 +488,25 @@ const Babl * babl_trc_gamma (double gamma);
  */
 const Babl * babl_trc       (const char *name);
 
+typedef enum {
+  BABL_ICC_DEFAULTS = 0,
+  BABL_ICC_COMPACT_TRC_LUT = 1,
+} BablICCFlags;
+
+/* babl_space_to_icc:
+ *
+ * Creates an ICCv2 RGB matrix profile for a babl space. The profiles strive to
+ * be as small and compact as possible, TRCs are stored as 1024 entry LUT(s).
+ *
+ * the result is allocated with malloc and you should free it when done.
+ */
+
+char *babl_space_to_icc (const Babl  *space,
+                         const char  *description,
+                         const char  *copyright,
+                         BablICCFlags flags,
+                         int         *icc_length);
+
 #ifdef __cplusplus
 }
 #endif
index 952aeb6ad8c35c389eec6ddb344df057b453c471..28c18513da9b696e4cd83f6d1a03a6500cac79c1 100644 (file)
@@ -41,6 +41,7 @@ babl_sampling
 babl_set_user_data
 babl_space
 babl_space_from_xyz
+babl_space_to_icc
 babl_chromaticities_make_space
 babl_space_get_rgbtoxyz
 babl_space_to_xyz